package com.pay.sdk.example;

import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.pay.sdk.service.channel3.ChannelThreePay;
import com.pay.sdk.service.channel4.ChannelFourPay;

/**
 * 通道4-一sandpay
 * @author Administrator
 *
 */
public class Channel4Example {

	public static void main(String[] args) {
        System.out.println("==重要== 调用任何API前，请先配置Configure类");
        quickPayExample();
    }
	
	  
	/**
	 * 快捷支付
	 */
    public static void quickPayExample(){
    	try {
    		String out_trade_no = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        	String order_time = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
    		String total_fee = "000000000012"; //单位分
        	String body = "快捷支付";
        	String notify_url = "http://paytest.shopping98.com/pay/apiNotify.shtml";
        	String time_expire = "30";//yyyyMMddHHmmss
        	String client_ip =  InetAddress.getLocalHost().getHostAddress();
        	//非必填字段
        	String return_url = "http://www.baidu.com";
        	String attach = "";
        	String device_info = "";
        	String result = ChannelFourPay.quickPay(out_trade_no, order_time,total_fee, body, client_ip, notify_url, time_expire, return_url,device_info, attach);
        	System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
    
    
    /**
     * 一网通订单查询
     */
    public static void prePayQueryExample(){
    	try {
    		String out_trade_no = "";
    		String transaction_id = "599678222580645888";
    		String out_transaction_id = "";
        	String result = ChannelThreePay.prePayQuery(out_trade_no, transaction_id, out_transaction_id);
        	System.out.println("一网通支付结果查询："+result);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
	
	
}
